package controller

import (
	"go-gin-api/app/service/article"

	"github.com/gin-gonic/gin"
)

// GetArticleList 获取全部文章
func GetArticleList(c *gin.Context) {
	var s article.ArticleListService
	if c.BindJSON(&s) == nil {
		res := s.GeArticle(c)
		c.JSON(200, res)
	}
}

// GetTypeList 获取文章标签
func GetTypeList(c *gin.Context) {
	res := article.GetType(c)
	c.JSON(200, res)
}

// GetArticleByID 根据id获取文章
func GetArticleByID(c *gin.Context) {
	res := article.GetDetail(c)
	c.JSON(200, res)
}

// AddArticle 添加文章
func AddArticle(c *gin.Context) {
	var s article.AddArticle
	if c.BindJSON(&s) == nil {
		res := s.AddArticleService(c)
		c.JSON(200, res)
	}
}

// DeleteArticle 删除文章
func DeleteArticle(c *gin.Context) {
	res := article.DeleteArticleByID(c)
	c.JSON(200, res)
}

// AddTypes 添加文章分类
func AddTypes(c *gin.Context) {
	var s article.AddTypesService
	if c.BindJSON(&s) == nil {
		res := s.AddTypes(c)
		c.JSON(200, res)
	}
}

// GetWords 获取标签云
func GetWords(c *gin.Context) {
	res := article.GetWords(c)
	c.JSON(200, res)
}
